package brainsplash.gyrusscope.game;

import brainsplash.gyrusscope.framework.gl.TextureRegion;
import android.graphics.Bitmap;
import android.util.Log;

public class Blast extends BaseObject{
	public int damage;
	public Spaceship parent;
	
	public Blast(TextureRegion sprite, int x, int y, int radius, float distanceFromCenter, float direction, float speed, int damage, Spaceship parent) {
		super(sprite, x, y, radius, distanceFromCenter, direction, speed);
		this.parent = parent;
		this.damage = damage;
	}

	public int getDamage() { return damage; }
	public void setDamage(int damage) { this.damage = damage; }
	
	public int collisionWith(Spaceship s) {
		if (parent instanceof Player) {
			if (s instanceof Enemy) {
			    int d = (int) (Math.sqrt(Math.pow(s.x-x, 2) + Math.pow(s.y-y, 2)));
				if (this.size / 2 + s.size / 2 > d) {
					s.health -= damage;
					if (s.health <= 0) {return 2;} 
					else {return 1;}
				}
			}
		}
		else if (s instanceof Player) {
		    int d = (int) (Math.sqrt(Math.pow(s.x-x, 2) + Math.pow(s.y-y, 2)));
			if (this.size / 2 + s.size / 2 > d) {
				Assets.vibrate(100);
				s.health -= damage;
				if (s.health <= 0) {return 2;} 
				else {return 1;}
			}
		}
		return 0;
	}
	
	public int collisionWith(Asteroid a) {
		if (parent instanceof Player) {
		    int d = (int) (Math.sqrt(Math.pow(a.x-x, 2) + Math.pow(a.y-y, 2)));
			if (this.size / 2 + a.size / 2 > d) {
				a.health -= damage;
				if (a.health <= 0) {return 2;} 
				else {return 1;}
			}
		}
		return 0;
	}
	
}
